﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using System.Data.SqlClient;
using CrystalDecisions.Shared;
using System.Configuration;
using System.IO;
using System.Data;
using Maintanence_Printing_Tool;


namespace Fitness_club
{
    public partial class bill_for_fees : Form
    {
        public static string constr = ConfigurationManager.AppSettings["ConStr"];

        SqlConnection con = new SqlConnection(constr);
        
        private int memberId=-1;

        private int billId = -1;
        
        public bill_for_fees()
        {
            InitializeComponent();
        }

        public bill_for_fees(int billId,int memberId)
        {
            InitializeComponent();
            this.memberId = memberId;
            this.billId = billId;
        }

        private void bill_for_fees_Load(object sender, EventArgs e)
        {
            try
            {
                //  printBill();
                DataTable dt = dbFunctions.getTable("pr_fetch_invoice '" + this.billId + "'");
                ReportDocument cryRpt = new ReportDocument();
                string reportPath = Path.GetDirectoryName(Application.ExecutablePath);
                string reportFullPath = Path.Combine(reportPath, "fees_report.rpt");
                cryRpt.Load(Application.StartupPath + "\\fees_report.rpt");
                cryRpt.SetDataSource(dt);

                crystalReportViewer1.ReportSource = cryRpt;
                crystalReportViewer1.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Bill Generated Failed, Try Again", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }                                                          
        }
    }
}
